#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define MAXN 800
#define MAXM 100005
using namespace std;

int n, bale, tsum;
bool good[2][MAXN][MAXN];

int main()
{
    freopen("baleshare.txt","r", stdin);
    for (int i=0;i<2;i++)
    for (int j=0;j<MAXN;j++)
    for (int k =0 ;k<MAXN;k++)
        good[i][j][k] = false;

    good[0][0][0] = true;
    scanf("%d", &n);
    for (int i=0;i<n;i++)
    {
        scanf("%d", &bale);
        tsum += bale;
        for (int j=0;j<MAXN;j++)
        for (int k=0;k<MAXN;k++)
            if (good[i%2][j][k])
            {
                good[(i+1)%2][j][k] = true;
                good[(i+1)%2][j+bale][k] = true;
                good[(i+1)%2][j][k+bale] = true;
            }
    }
    int ans = MAXN;
    for (int i=0;i<MAXN;i++)
    for (int j=0;j<MAXN;j++)
        if (good[n%2][i][j])
            ans = min(ans, max(i, max(j, tsum - (i+j))));
    printf("%d\n", ans);
    return 0;
}
